package com.elinkway.infinitemovies.view;

import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.elinkway.infinitemovies.utils.UIs;
import com.le123.ysdq.R;

/**
 * Author: liuxiaojiang(liuxiaojiang@lvideo.com)
 * Date: 2016-09-02
 * Time: 15:02
 * Description: FIXME
 */
public class CommonTitleView extends FrameLayout {

    private TextView titleTv;

    private TextView rightTv;

    private RelativeLayout rightCloseIv;

    private RelativeLayout mHeaderRl;

    public CommonTitleView(Context context) {
        this(context, null);
    }

    public CommonTitleView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CommonTitleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(context).inflate(R.layout.popup_header_layout, this);
        mHeaderRl = (RelativeLayout) findViewById(R.id.header_rl);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            mHeaderRl.setBackground(getResources().getDrawable(R.drawable.rectangle_with_bottom_border));
            mHeaderRl.setPadding(0, UIs.dipToPx(8), 0, UIs.dipToPx(8));
        }
        titleTv = (TextView) findViewById(R.id.title_tv);
        rightCloseIv = (RelativeLayout) findViewById(R.id.right_close_iv);
    }

    public void setTitleText(String text) {
        titleTv.setText(text);
    }

    public void setRightText(String text) {
        rightTv.setText(text);
    }

    public void isRightIvShow(boolean isShow){
        if(isShow){
            rightCloseIv.setVisibility(View.VISIBLE);
        }else{
            rightCloseIv.setVisibility(View.GONE);
        }
    }
}
